Skip to content

Quantity input change #1485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2025
Merged

Quantity input change #1485

merged 2 commits into from
Jun 30, 2025

Conversation

w3bdesign
Copy link
Owner

No description provided.

@w3bdesign w3bdesign self-assigned this Jun 30, 2025
Copy link

vercel bot commented Jun 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxtjs-woocommerce ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2025 2:16am

Copy link

@w3bdesign w3bdesign merged commit 62e0b77 into master Jun 30, 2025
7 of 8 checks passed
import { formatPrice } from "@/utils/functions";

const isRemoving = ref(false);
const isUpdating = ref(false);
const localQuantity = ref(props.product.quantity);

Check warning

Code scanning / CodeQL

Variable not declared before use Warning

Variable 'props' is used before its
declaration
.

Copilot Autofix

AI 8 days ago

To fix the issue, the declaration of props should be moved above its first usage on line 59. This ensures that the variable is declared before it is used, improving code readability and adhering to best practices. Specifically, the defineProps call for props should be relocated to the top of the <script setup> block, before any other code that references props.


Suggested changeset 1
components/Cart/CartItem.vue

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/components/Cart/CartItem.vue b/components/Cart/CartItem.vue
--- a/components/Cart/CartItem.vue
+++ b/components/Cart/CartItem.vue
@@ -56,2 +56,9 @@
 
+const props = defineProps({
+  product: {
+    type: Object,
+    required: true,
+  },
+});
+
 const isRemoving = ref(false);
@@ -67,9 +74,2 @@
 
-const props = defineProps({
-  product: {
-    type: Object,
-    required: true,
-  },
-});
-
 const emit = defineEmits(["remove", "update-quantity"]);
EOF
@@ -56,2 +56,9 @@

const props = defineProps({
product: {
type: Object,
required: true,
},
});

const isRemoving = ref(false);
@@ -67,9 +74,2 @@

const props = defineProps({
product: {
type: Object,
required: true,
},
});

const emit = defineEmits(["remove", "update-quantity"]);
Copilot is powered by AI and may make mistakes. Always verify output.
import { formatPrice } from "@/utils/functions";

const isRemoving = ref(false);
const isUpdating = ref(false);
const localQuantity = ref(props.product.quantity);

Check failure

Code scanning / CodeQL

Property access on null or undefined Error

The base expression of this property access is always undefined.

Copilot Autofix

AI 8 days ago

To fix the issue, the code should directly access the product prop defined by defineProps instead of attempting to access props.product. In Vue's <script setup> syntax, props are directly accessible as variables without needing to reference a props object. This change ensures that the code adheres to Vue's conventions and avoids runtime errors.

The following changes will be made:

  1. Replace all instances of props.product with product.
  2. Ensure that the product prop is correctly accessed throughout the script.

Suggested changeset 1
components/Cart/CartItem.vue

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/components/Cart/CartItem.vue b/components/Cart/CartItem.vue
--- a/components/Cart/CartItem.vue
+++ b/components/Cart/CartItem.vue
@@ -58,6 +58,6 @@
 const isUpdating = ref(false);
-const localQuantity = ref(props.product.quantity);
+const localQuantity = ref(product.quantity);
 
 watch(
-  () => props.product.quantity,
+  () => product.quantity,
   (newVal) => {
@@ -81,3 +81,3 @@
   isRemoving.value = true;
-  emit("remove", props.product.key);
+  emit("remove", product.key);
 };
@@ -85,5 +85,5 @@
 const onQuantityChange = (newQuantity) => {
-  if (newQuantity === props.product.quantity || isUpdating.value) return;
+  if (newQuantity === product.quantity || isUpdating.value) return;
   isUpdating.value = true;
-  emit("update-quantity", { key: props.product.key, quantity: newQuantity });
+  emit("update-quantity", { key: product.key, quantity: newQuantity });
   // UI disables controls while updating; parent resets isUpdating via prop or reactivity
EOF
@@ -58,6 +58,6 @@
const isUpdating = ref(false);
const localQuantity = ref(props.product.quantity);
const localQuantity = ref(product.quantity);

watch(
() => props.product.quantity,
() => product.quantity,
(newVal) => {
@@ -81,3 +81,3 @@
isRemoving.value = true;
emit("remove", props.product.key);
emit("remove", product.key);
};
@@ -85,5 +85,5 @@
const onQuantityChange = (newQuantity) => {
if (newQuantity === props.product.quantity || isUpdating.value) return;
if (newQuantity === product.quantity || isUpdating.value) return;
isUpdating.value = true;
emit("update-quantity", { key: props.product.key, quantity: newQuantity });
emit("update-quantity", { key: product.key, quantity: newQuantity });
// UI disables controls while updating; parent resets isUpdating via prop or reactivity
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant